<template>
	<view class="page">
		<view class="list">
			<view v-for="(item, index) in list" :key="index" class="item"
				@click="to('/pages/IndexPages/doctorDetail/main?id=' + item.doctorId)">
				<view class="title">
					<view>{{ item.doctorName }}</view>
					<image v-if="item.sex == '2'" src="/static/images/female.png" />
					<image v-if="item.sex == '1'" src="/static/images/male.png" />
					<view>{{ item.departmentName + '&nbsp;'+ item.doctorPosition }}</view>
					<image class="delete" src="/static/images/ic_delete.png" @click.stop="clickDelete(item.id)"></image>
				</view>
				<view class="wrap"><text>{{ item.hospitalName }}</text></view>
				<view class="taglist">
					<view>医生印象：</view>
					<view v-for="(val, k) in item.commentTagsList" :key="k">
						{{ k > 0 ? '，' : ''}}
						{{ val.tagName }}
					</view>
				</view>
				<view class="detail">
					<view class="text">
						{{ item.additionalRemark }}
					</view>
					<view v-if="item.commentImage" class="imgBox" @click.stop>
						<image class="img" v-for="(x, y) in item.imgList" :key="y" :src="x"
							@click="preview(x, item.imgList)" mode="aspectFill"></image>
					</view>
				</view>
				<view class="bottom">
					<view class="disease" v-if="item.diseaseName">{{item.diseaseName}}</view>
					<view class="right-box">{{item.createTime}}</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				finished: false,
				pageNo: 1,
				total: 0,
				list: []
			}
		},
		onLoad() {
			this.init();
		},
		onPullDownRefresh() {
			this.init();
		},
		onReachBottom() {
			this.getUserlist();
		},
		methods: {
			init() {
				this.finished = false;
				this.pageNo = 1;
				this.list = [];
				this.getList();
			},
			getList() {
				this.$api.http('/hospital/medicalDoctorEvaluate/queryPageList', 'GET', {
					pageNo: this.pageNo++,
					pageSize: 10
				}, res => {
					if (res.data.result.records.length == 0) {
						this.finished = true;
					}
					this.list = this.list.concat(
						...res.data.result.records.map(item => {
							return {
								...item,
								showImage: false,
								imgList: item.commentImage ? item.commentImage.split(",") : []
							};
						})
					);
					uni.stopPullDownRefresh();
				})
			},
			preview(current, imgList) {
				this.$Imgpreview(current, imgList);
			},
			clickDelete(id) {
				const that = this
				uni.showModal({
					title: '提示',
					content: '您确定删除该点评吗？',
					success(res) {
						if (res.confirm) {
							that.$api.http('/hospital/medicalDoctorEvaluate/delete/' + id, 'GET', {
									id
								},
								res => {
									that.init();
								})
						}
					}
				})
			},
			to(url) {
				uni.navigateTo({
					url,
				})
			},
		}
	}
</script>

<style lang="less" scoped>
	.page {
		width: 100%;
		background-color: #f1efef;

		.list {
			background-color: #ffffff;
			padding: 10rpx 10rpx 0rpx;

			.item {
				padding: 30rpx;
				border-bottom: 1rpx solid #F1F1F1;

				view {
					display: flex;
					align-items: center;
				}

				.title {
					position: relative;

					view:nth-child(1) {
						color: #333333;
						font-size: 32rpx;
					}

					image {
						width: 30rpx;
						height: 30rpx;
						margin: 0 10rpx;
					}

					view:nth-child(3) {
						color: #666666;
						font-size: 22rpx;
					}

					.delete {
						position: absolute;
						top: 0;
						right: 0;
						width: 28.5rpx;
						height: 33.75rpx;
					}
				}

				.wrap {
					margin-top: 10upx;
					font-size: 24rpx;
				}

				.taglist {
					display: flex;
					flex-wrap: wrap;
					margin-top: 15rpx;
					font-size: 24rpx;
					color: #999999;
					margin: 15rpx 0;
				}

				.detail {
					display: flex;
					flex-direction: column;
					align-items: flex-start;
					padding-bottom: 30rpx;

					.text {
						margin-bottom: 10rpx;
						word-break: break-all;
						font-size: 28rpx;
						color: #333333;
					}

					.imgBox {
						.img {
							width: 220rpx;
							height: 250rpx;
							margin-right: 8rpx;
						}
					}
				}

				.bottom {
					margin-top: 10rpx;
					display: flex;
					align-items: center;
					align-content: center;
					justify-content: space-between;

					.disease {
						padding: 10rpx 25rpx;
						color: #F48712;
						font-size: 26rpx;
						border-radius: 30rpx;
						background-color: #FEF5EE;
					}

					.right-box {
						color: #999999;
						font-size: 28rpx;
					}
				}
			}
		}
	}
</style>
